#include "sqlite_form.h"
#include "ui_sqlite_form.h"

sqlite_form::sqlite_form(mainwindowCallBack cb) :
    m_MainCallback(cb),
    ui(new Ui::sqlite_form)
{
    ui->setupUi(this);

    QString str_test_01 = "test sql: <delete from tb_daily_record where id = 3;>";
    QString str_test_02 = "test sql: <select * from tb_daily_record;>";
    m_MainCallback(str_test_01);
    m_MainCallback(str_test_02);

    ui->le_modify->setToolTip(str_test_01);
    ui->le_select->setToolTip(str_test_02);

    connect(ui->wgt_sqlite,&SqliteTableWidget::sigSendMsg,this,[&](QString info){
        m_MainCallback(info);
    });
}

sqlite_form::~sqlite_form()
{
    delete ui;
}

void sqlite_form::on_pb_modify_clicked()
{
    QString sql = ui->le_modify->text().trimmed();
    ui->wgt_sqlite->setQuery(sql);
}

void sqlite_form::on_pb_select_clicked()
{
    QString sql = ui->le_select->text().trimmed();
    ui->wgt_sqlite->setQuery(sql);
}
